package com.yf.cn.entity.common;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/*********************************************************
 ** 公共的实体类
 ** <br><br>
 ** @author: yangfeng
 ** @date: 2023/12/11 14:34
 ** @version: 1.0.0
 *********************************************************/
@Data
public class BaseEntity implements Serializable {
    /**
     * 数据创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @TableField(fill = FieldFill.INSERT)
    @OrderBy
    private LocalDateTime crtTime;
    /**
     * 数据更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime upTime;
    /**
     * 物理删除标识
     */
    @TableLogic(value = "1", delval = "0")
    private Integer delFlag;

    @Version
    @TableField(fill = FieldFill.INSERT)   //添加元素时自动填充
    private Integer version;

}
